﻿
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Gola.VN.Scb.Web.Common.Entities;

namespace Gola.VN.Scb.Web.Common
{
    public static class Extension
    {
        #region 1. string
        public static string ConvertToUnSign(this string text)
        {
            for (int i = 33; i < 48; i++)
            {
                text = text.Replace(((char)i).ToString(), "");
            }

            for (int i = 58; i < 65; i++)
            {
                text = text.Replace(((char)i).ToString(), "");
            }

            for (int i = 91; i < 97; i++)
            {
                text = text.Replace(((char)i).ToString(), "");
            }

            for (int i = 123; i < 127; i++)
            {
                text = text.Replace(((char)i).ToString(), "");
            }
            text = text.Replace("-", "").Replace("  ", " ");
            text = text.Replace(" ", "-").ToLower();

            Regex regex = new Regex(@"\p{IsCombiningDiacriticalMarks}+");

            string strFormD = text.Normalize(System.Text.NormalizationForm.FormD);

            return regex.Replace(strFormD, String.Empty).Replace("\u0111", "d").Replace("\u0110", "D");

        }

        public static string RemoveHtmlTag(this string input)
        {
            return System.Text.RegularExpressions.Regex.Replace(input, @"<(.|\n)*?>", " ").Replace("  "," ");
        }
        #endregion
    }
}
